package com.qcby.controller;

import com.qcby.entity.Student;
import com.qcby.entity.vo.StudentVo;
import com.qcby.service.StudentService;
import com.qcby.util.ResultObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.Arrays;

/**
 * @author haozeWang
 * @create 2021-08-23 17:54
 */
@Controller
@RequestMapping("/student")
public class StudentController {
    @Autowired
    private StudentService studentService;
    @RequestMapping("/selectall")
    @ResponseBody
    public ResultObject selectAll(StudentVo studentVo){
        ResultObject object = studentService.selectAll(studentVo);
        return object;
    }
    /*删除单个学生*/
    @RequestMapping("/delete")
    @ResponseBody
    public ResultObject delete(Integer id){
        ResultObject object = studentService.delete(id);
        return object;
    }
    /*添加单个学生*/
    @RequestMapping("/add")
    @ResponseBody
    public ResultObject add(Student student){
        ResultObject object = studentService.add(student);
        return object;
    }
    /*修改单个学生*/
    @RequestMapping("/update")
    @ResponseBody
    public ResultObject update(Student student){
        ResultObject object = studentService.update(student);
        return object;
    }
    /*批量删除学生*/
    @RequestMapping("/deletedisp")
    @ResponseBody
    public ResultObject deletedisp(@RequestBody ArrayList<Integer> ids){
       ResultObject object = studentService.deleteDisp(ids);
        return object;
    }

}
